package io.github.bloquesoft.entity.storage.mybatisplus.springboot;

import io.github.bloquesoft.entity.cache.EntityDefinitionCache;
import io.github.bloquesoft.entity.cache.local.EntityDefinitionCacheLocal;
import io.github.bloquesoft.entity.clazz.ClassEntityDefinitionFactory;
import io.github.bloquesoft.entity.clazz.ClassEntityExecutor;
import io.github.bloquesoft.entity.clazz.ClassEntityExecutorImpl;
import io.github.bloquesoft.entity.storage.PojoOperation;
import io.github.bloquesoft.entity.storage.analysis.StorageEntityAnalysisResult;
import io.github.bloquesoft.entity.storage.mybatisplus.ClassMapperBeanRegister;
import io.github.bloquesoft.entity.storage.mybatisplus.ClassMapperBeanRegisterImpl;
import io.github.bloquesoft.entity.storage.mybatisplus.PojoOperationMapperImpl;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class ConfigurationBean {

    @Bean
    public ClassMapperBeanRegister classMapperBeanRegisterBean() {
        return new ClassMapperBeanRegisterImpl();
    }

    @Bean
    public EntityDefinitionCache entityDefinitionCache() {
        return new EntityDefinitionCacheLocal();
    }

    @Bean
    public ClassEntityDefinitionFactory classEntityDefinitionFactory(EntityDefinitionCache entityDefinitionCache) {
        return new ClassEntityDefinitionFactory(entityDefinitionCache);
    }

    @Bean
    public PojoOperation pojoOperationBean(ClassMapperBeanRegister register) {
        return new PojoOperationMapperImpl(register);
    }

    @Bean
    public StorageEntityAnalysisResult storageEntityAnalysisResult() {
        return new StorageEntityAnalysisResult();
    }

    @Bean
    public ClassEntityExecutor classEntityExecutor(PojoOperation pojoOperation, ClassEntityDefinitionFactory classEntityDefinitionFactory, StorageEntityAnalysisResult storageEntityAnalysisResult) {
        return new ClassEntityExecutorImpl(pojoOperation, classEntityDefinitionFactory, storageEntityAnalysisResult);
    }
}
